package com.jianggy.facade;

import java.io.File;
import java.io.IOException;

/**
 * 读取文件类
 * @author jianggy
 * @time 2018年9月20日 上午11:33:07
 * @description
 */
public class FileReader {
	public String read(String path) {
		java.io.FileReader reader = null;
		StringBuilder builder = new StringBuilder();
		try {
			reader = new java.io.FileReader(new File(path));
			char[] charBuffer = new char[100];
			int len = 0;
			while ((len = reader.read(charBuffer)) != -1) {
				builder.append(new String(charBuffer, 0, len));
				System.out.println(builder.toString());
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (reader != null) {
				try {
					reader.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}
		return builder.toString();

	}

}
